#include <thread>
#include <iostream>
#include <vector>
#include <mutex>

int32_t data[8] = {1,2,3,4,5,6,7,8}; 

struct Foo {
    int32_t get() const { return x; }
    void set(int32_t x) { this->x = x; }
    int32_t x;
} foo;

void thread_write1() {
    for (;;) { for (auto v : data) { foo.set(v); } }
}

void thread_write2() {
    for (;;) { for (auto v : data) { foo.set(v); } }
}

void thread_read() {
    for (;;) { printf("%d", foo.get()); }
}

int main(){
	std::thread t1(thread_write1);
	std::thread t2(thread_write2);
	std::thread t3(thread_read);
	t1.join();
	t2.join();
	t3.join();
	return 0;
	
}